package cn.stylefeng.guns.utils.map;

import cn.stylefeng.guns.utils.HttpClientUtil;
import com.alibaba.fastjson.JSON;

public class GaoDeMapUtil {
    private static String api = "https://restapi.amap.com";

    public static String key = "c5457a437521b957f10b7eaf7a5a63a9";

    /**
     * 获取城市信息
     * @param location
     * @return
     */
    public static String Geocode(String location){
        String url = api+"/v3/geocode/regeo?key="+key+"&location="+location+"&poitype=&radius=1000&extensions=all&batch=false&roadlevel=0";
        String result = HttpClientUtil.doGet(url);
        return result;
    }

    public static GaoDeDistanceResult distance(String begLocation,String endLocation){
        String url = api + "/v3/distance?key="+key+"&origins="+begLocation+"&destination="+endLocation+"&type=1";
        String result = HttpClientUtil.doGet(url);
        return JSON.parseObject(result,GaoDeDistanceResult.class);
    }

    /**
     * 百度地图坐标转高德
     * @param location
     * @return
     */
    public static GaodeTransitionResult transition(String location){
        String url = api+"/v3/assistant/coordinate/convert?locations="+location+"&coordsys=baidu&key="+key;
        String result = HttpClientUtil.doGet(url);
        return JSON.parseObject(result,GaodeTransitionResult.class);
    }
}
